-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Skip comments in Ruby files when checking for class names #19243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
bc1c637 to
fa2be75
Compare
WalkthroughAdds an Pre-merge checks✅ Passed checks (5 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
crates/oxide/src/extractor/arbitrary_property_machine.rs(3 hunks)crates/oxide/src/extractor/pre_processors/ruby.rs(5 hunks)crates/oxide/src/extractor/pre_processors/test-fixtures/haml/dst-17051.haml(0 hunks)
💤 Files with no reviewable changes (1)
- crates/oxide/src/extractor/pre_processors/test-fixtures/haml/dst-17051.haml
🧰 Additional context used
🧬 Code graph analysis (1)
crates/oxide/src/extractor/pre_processors/ruby.rs (2)
crates/oxide/src/extractor/candidate_machine.rs (1)
next(29-169)crates/oxide/src/extractor/string_machine.rs (1)
next(32-68)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Linux
- GitHub Check: Linux / postcss
- GitHub Check: Linux / vite
- GitHub Check: Linux / upgrade
RobinMalfait
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but not sure about the !important.
Can you also add a changelog entry?
crates/oxide/src/extractor/pre_processors/test-fixtures/haml/dst-17051.haml
Show resolved
Hide resolved
|
Yeah I was not gonna change that part. It's unrelated anyway. Will get the change log updated. |
Unless it’s part of `!important` at the end
42f48be to
f381118
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
CHANGELOG.md(1 hunks)crates/oxide/src/extractor/arbitrary_property_machine.rs(3 hunks)crates/oxide/src/extractor/pre_processors/ruby.rs(5 hunks)crates/oxide/src/extractor/pre_processors/test-fixtures/haml/dst-17051.haml(0 hunks)
💤 Files with no reviewable changes (1)
- crates/oxide/src/extractor/pre_processors/test-fixtures/haml/dst-17051.haml
🧰 Additional context used
🧬 Code graph analysis (1)
crates/oxide/src/extractor/pre_processors/ruby.rs (2)
crates/oxide/src/extractor/candidate_machine.rs (1)
next(29-169)crates/oxide/src/extractor/string_machine.rs (1)
next(32-68)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Linux
- GitHub Check: Linux / cli
- GitHub Check: Linux / upgrade
- GitHub Check: Linux / postcss
- GitHub Check: Linux / vite
- GitHub Check: Linux / webpack
| // Replace comments in Ruby files | ||
| b'#' => { | ||
| result[cursor.pos] = b' '; | ||
| cursor.advance(); | ||
|
|
||
| while cursor.pos < len { | ||
| match cursor.curr { | ||
| // End of the comment | ||
| b'\n' => break, | ||
|
|
||
| // Everything else is part of the comment and replaced | ||
| _ => { | ||
| result[cursor.pos] = b' '; | ||
| cursor.advance(); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| cursor.advance(); | ||
| continue; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid clobbering percent literals when stripping comments.
Treating every # outside of quoted strings as the start of a comment nukes valid Ruby percent literals like %r#foo#bar# or %i#klass#, because this loop replaces everything from the delimiter onward with spaces. After preprocessing, the literal body is gone and the extractor can’t see classes tucked inside. Please keep %r/%i/%s-style delimiters (and similar % forms) intact—e.g., bail out of the comment branch when the # immediately follows a %[a-zA-Z] sequence—so we only blank true comments.
🤖 Prompt for AI Agents
In crates/oxide/src/extractor/pre_processors/ruby.rs around lines 121 to 142,
the comment-stripping branch treats every '#' as the start of a comment and thus
clobbers Ruby percent-literals like %r#...# or %i#...#; change the branch to
detect when the '#' is actually the delimiter of a percent-literal and skip
comment removal in that case. Concretely, before turning the '#' into a space
and entering the comment loop, check the two bytes immediately before cursor (or
the original buffer at cursor.pos-2 and cursor.pos-1) and if they form '%'
followed by an ASCII letter (/[A-Za-z]/) then do not treat this '#' as a comment
(bail out of the comment branch and continue normal scanning), otherwise proceed
with the existing comment-blanking logic.
Fixes #19239